package com.jindy.module.assistmaterials.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.assistmaterials.domain.AssistMaterials;
import com.jindy.module.assistmaterials.service.IAssistMaterialsService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * fucaishengchengController
 * 
 * @author jindy
 * @date 2023-02-16
 */
@RestController
@RequestMapping("/module/materials")
public class AssistMaterialsController extends BaseController
{
    @Autowired
    private IAssistMaterialsService assistMaterialsService;

    /**
     * 查询fucaishengcheng列表
     */
    @PreAuthorize("@ss.hasPermi('module:materials:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssistMaterials assistMaterials)
    {
        startPage();
        List<AssistMaterials> list = assistMaterialsService.selectAssistMaterialsList(assistMaterials);
        return getDataTable(list);
    }

    /**
     * 导出fucaishengcheng列表
     */
    @PreAuthorize("@ss.hasPermi('module:materials:export')")
    @Log(title = "fucaishengcheng", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssistMaterials assistMaterials)
    {
        List<AssistMaterials> list = assistMaterialsService.selectAssistMaterialsList(assistMaterials);
        ExcelUtil<AssistMaterials> util = new ExcelUtil<AssistMaterials>(AssistMaterials.class);
        util.exportExcel(response, list, "fucaishengcheng数据");
    }

    /**
     * 获取fucaishengcheng详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:materials:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(assistMaterialsService.selectAssistMaterialsById(id));
    }

    /**
     * 新增fucaishengcheng
     */
    @PreAuthorize("@ss.hasPermi('module:materials:add')")
    @Log(title = "fucaishengcheng", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssistMaterials assistMaterials)
    {
        return toAjax(assistMaterialsService.insertAssistMaterials(assistMaterials));
    }

    /**
     * 修改fucaishengcheng
     */
    @PreAuthorize("@ss.hasPermi('module:materials:edit')")
    @Log(title = "fucaishengcheng", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssistMaterials assistMaterials)
    {
        return toAjax(assistMaterialsService.updateAssistMaterials(assistMaterials));
    }

    /**
     * 删除fucaishengcheng
     */
    @PreAuthorize("@ss.hasPermi('module:materials:remove')")
    @Log(title = "fucaishengcheng", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(assistMaterialsService.deleteAssistMaterialsByIds(ids));
    }
}
